package com.redlion.object;

import org.andengine.entity.modifier.IEntityModifier;
import org.andengine.entity.sprite.Sprite;
import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.redlion.Game;

public class Comet extends AbstractObject {
	private static final String TAG = "Comet";
	public IEntityModifier rotation;

	public Comet(Vector2 position, ITextureRegion textureRegion, FixtureDef fixtureDef) {
		super(position, textureRegion, fixtureDef);
	}

	@Override
	protected void createBody(FixtureDef fixtureDef) {
		body = PhysicsFactory.createCircleBody(Game.mPhysicsWorld, sprite, BodyType.DynamicBody, fixtureDef);
		body.setBullet(false);
	}

	@Override
	protected void createSprite() {

	}

	@Override
	protected void createSprite(float px, float py) {
		sprite = new Sprite(px - (mTextureRegion.getWidth() / 2), py - (mTextureRegion.getHeight() / 2), mTextureRegion,
				Game.gameActivity.getVertexBufferObjectManager());
	}

	public void activate() {
		sprite.setIgnoreUpdate(false);
		sprite.setVisible(true);
		body.setAwake(true);
		body.setActive(true);
		body.setUserData(this);
	}

	public void deactivate() {
		sprite.setIgnoreUpdate(true);
		sprite.setVisible(false);
		body.setUserData(null);
		body.setAwake(false);
		body.setActive(false);
		// sprite.reset();
	}

}
